var Rx = require('rxjs');
var operators = require("rxjs/operators");
var SERVER_CONST = require("../server-const");
var express = require('express');
var router = express.Router();
var model = require("../model/chatModel");
var user = model.user;
var channels = model.channels;
var teams = model.teams;
var channelMembers = model.channelMembers;
var teamMembers = model.teamMembers;
var util = require("../server-util/util");
var mongoose = require("mongoose");
var post = model.post;

//这两个接口是客户端传什么过来,就返回什么回去
router.get('/testGET', function (req, res, next) {
    res.json({
        data: req.query
    })
})
//这两个接口是客户端传什么过来,就返回什么回去
router.get('/testPOST', function (req, res, next) {
    res.json({
        data: req.body
    })
})
router.get('/sort_content_list', function (req, res, next) {
    let contentId = req.query.contentId
    if (contentId != "10") {
        util.res.success({
            res,
            data: [
                {
                    "id": 1,
                    "section": "手机",
                    "goods": [
                        {
                            "goods_id": 3,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/f0e283f74845939fd24d53f7fb1d35c1.png?width=120&height=120",
                            "goods_name": "小米6"
                        },
                        {
                            "goods_id": 4,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/88bc9af6c3bd4e7a695060fe628971e8.png?width=120&height=120",
                            "goods_name": "小米Max 2"
                        },
                        {
                            "goods_id": 5,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/661f8ad7f2014f352e3a47fbb5ee2939.png?width=120&height=120",
                            "goods_name": "红米4X"
                        },
                        {
                            "goods_id": 6,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/ea6275142315b78422e4f047406fc76c.png?width=120&height=120",
                            "goods_name": "红米Note 4X"
                        }
                    ]
                },
                {
                    "id": 2,
                    "section": "电视",
                    "goods": [
                        {
                            "goods_id": 3,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/efb682b76a29411fd26d990971992c3e.png?width=120&height=120",
                            "goods_name": "49英寸"
                        },
                        {
                            "goods_id": 4,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/a68d31ccb3ac07f289abc39a5682f334.png?width=120&height=120",
                            "goods_name": "55英寸"
                        },
                        {
                            "goods_id": 5,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/068cd93230bb3d93c80f42b0dba6d5f4.png?width=120&height=120",
                            "goods_name": "65英寸"
                        }
                    ]
                },
                {
                    "id": 2,
                    "section": "电脑",
                    "goods": [
                        {
                            "goods_id": 3,
                            "goods_thumb": "https://i8.mifile.cn/b2c-mimall-media/f0d7f8167e14f0c70fd84aa6cb321cb6.png?width=120&height=120",
                            "goods_name": "笔记本12.5"
                        }
                    ]
                },
                {
                    "id": 3,
                    "section": "标题3",
                    "goods": [
                        {
                            "goods_id": 3,
                            "goods_thumb": "http://i8.mifile.cn/v1/a1/1ef4e430-b65a-2655-791a-680a49668005.webp?width=720&height=720",
                            "goods_name": "品牌1"
                        },
                        {
                            "goods_id": 4,
                            "goods_thumb": "http://i8.mifile.cn/v1/a1/1ef4e430-b65a-2655-791a-680a49668005.webp?width=720&height=720",
                            "goods_name": "品牌2"
                        },
                        {
                            "goods_id": 5,
                            "goods_thumb": "http://i8.mifile.cn/v1/a1/1ef4e430-b65a-2655-791a-680a49668005.webp?width=720&height=720",
                            "goods_name": "品牌3"
                        },
                        {
                            "goods_id": 6,
                            "goods_thumb": "http://i8.mifile.cn/v1/a1/1ef4e430-b65a-2655-791a-680a49668005.webp?width=720&height=720",
                            "goods_name": "品牌4"
                        },
                        {
                            "goods_id": 7,
                            "goods_thumb": "http://i8.mifile.cn/v1/a1/T1SexQBgCT1RC2b46K.webp",
                            "goods_name": "品牌5"
                        },
                        {
                            "goods_id": 8,
                            "goods_thumb": "http://i8.mifile.cn/v1/a1/T1SexQBgCT1RC2b46K.webp",
                            "goods_name": "品牌6"
                        }
                    ]
                }
            ]
        })
    } else {
        util.res.error({
            res,
            msg: "contendId=10,没有数据"
        });
    }
})
router.get('/index', function (req, res, next) {
    util.res.success({
        res,
        data: [
            {
                "goodsId": 0,
                "spanSize": 4,
                "banners": [
                    "https://i8.mifile.cn/v1/a1/251f0880-423e-fa2d-3c18-1d3ec23f9912.webp",
                    "https://i8.mifile.cn/v1/a1/49dfd019-9504-abb5-34bb-26f425b67e45.webp",
                    "https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/b9540da01aef9a00a5c640b1c98b955a.jpg"
                ]
            },
            {
                "goodsId": 1,
                "text": "明星单品",
                "imageUrl": "https://i8.mifile.cn/v1/a1/1d338200-1be1-f868-9695-9d5ae0d6c2c6.webp",
                "spanSize": 4
            },
            {
                "goodsId": 2,
                "text": "小米5c  64GB 移动版",
                "imageUrl": "https://i8.mifile.cn/v1/a1/04629084-7810-d1fb-6f4a-a0c52433ca29.webp?width=360&height=360",
                "spanSize": 2
            },
            {
                "goodsId": 3,
                "text": "米家智能摄像机",
                "imageUrl": "https://i8.mifile.cn/v1/a1/375bd3a4-aab9-f77b-f6a1-5dbf01087495.webp?width=360&height=360",
                "spanSize": 2
            },
            {
                "goodsId": 4,
                "imageUrl": "https://i8.mifile.cn/v1/a1/656a5863-6af1-6302-4e36-a33bd49e45cb.webp?width=360&height=360",
                "spanSize": 2
            },
            {
                "goodsId": 5,
                "imageUrl": "https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/cbcdb6c054d45c1afc955c87329e96f1.jpg?width=360&height=360",
                "spanSize": 2
            },
            {
                "goodsId": 6,
                "imageUrl": "https://i8.mifile.cn/v1/a1/f093e0a8-e3d8-4fc8-deb7-af25ea3d8663.webp?width=360&height=360",
                "spanSize": 2
            },
            {
                "goodsId": 7,
                "imageUrl": "https://i8.mifile.cn/v1/a1/b6c55f3b-d4ac-b2be-8d7c-3c818a79030a.webp?width=360&height=360",
                "spanSize": 2
            },
            {
                "goodsId": 5,
                "text": "智能生活，从这里开始",
                "spanSize": 4
            },
            {
                "goodsId": 5,
                "text": "测试描述5",
                "imageUrl": "https://i8.mifile.cn/v1/a1/6cc739d8-ae51-779a-3707-2f1d20a558bf.webp?width=720&heihgt=440",
                "spanSize": 4
            },
            {
                "goodsId": 6,
                "text": "测试描述6",
                "imageUrl": "http://imgsrc.baidu.com/baike/pic/item/0b55b319ebc4b745a58395aecffc1e178a821576.jpg",
                "spanSize": 4
            },
            {
                "goodsId": 5,
                "text": "我又是野广告",
                "spanSize": 4
            }
        ]
    });
});
router.get('/shop_cart', function (req, res, next) {
    util.res.success({
        res,
        data: [
            {
                "title": "小米6 6GB+128GB",
                "desc": "变焦双摄，4 轴防抖 骁龙835",
                "id": 1,
                "price": 2899,
                "count": 1,
                "thumb": "https://i8.mifile.cn/b2c-mimall-media/f0e283f74845939fd24d53f7fb1d35c1.png?width=120&height=120"
            },
            {
                "title": "悦米机械键盘",
                "desc": "87键 铝合金机身 TTC 红轴 简约百搭",
                "id": 3,
                "count": 2,
                "price": 299,
                "thumb": "https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/12925f99d858e3155c4bb3ecd1f37ae7.png?width=120&height=120"
            },
            {
                "title": "无线鼠标",
                "desc": "阳极氧化铝合金外壳+ABS材质",
                "id": 3,
                "count": 1,
                "price": 99,
                "thumb": "https://i8.mifile.cn/v1/a1/2ca61893-68b9-d0a0-5f85-bdc28e655a3e.jpg?width=120&height=120"
            },
            {
                "title": "USB快速充电线",
                "desc": "坚固耐用的USB接口",
                "id": 3,
                "count": 2,
                "price": 19,
                "thumb": "https://i8.mifile.cn/v1/a1/b0580f26-ce5f-a53e-c4ef-6adaf4b798f9.jpg?width=120&height=120"
            },
            {
                "title": "智能电饭煲",
                "desc": "压力IH加热技术 3L容量",
                "id": 3,
                "count": 2,
                "price": 999,
                "thumb": "https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/12925f99d858e3155c4bb3ecd1f37ae7.png?width=120&height=120"
            }
        ]
    });
})
router.get('/shop_cart_count', function (req, res, next) {
    util.res.success({
        res,
        data: [
            {
                "title": "小米6 6GB+128GB",
                "desc": "变焦双摄，4 轴防抖 骁龙835",
                "id": 1,
                "price": 2899,
                "count": 1,
                "thumb": "https://i8.mifile.cn/b2c-mimall-media/f0e283f74845939fd24d53f7fb1d35c1.png?width=120&height=120"
            },
            {
                "title": "悦米机械键盘",
                "desc": "87键 铝合金机身 TTC 红轴 简约百搭",
                "id": 3,
                "count": 2,
                "price": 299,
                "thumb": "https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/12925f99d858e3155c4bb3ecd1f37ae7.png?width=120&height=120"
            },
            {
                "title": "无线鼠标",
                "desc": "阳极氧化铝合金外壳+ABS材质",
                "id": 3,
                "count": 1,
                "price": 99,
                "thumb": "https://i8.mifile.cn/v1/a1/2ca61893-68b9-d0a0-5f85-bdc28e655a3e.jpg?width=120&height=120"
            },
            {
                "title": "USB快速充电线",
                "desc": "坚固耐用的USB接口",
                "id": 3,
                "count": 2,
                "price": 19,
                "thumb": "https://i8.mifile.cn/v1/a1/b0580f26-ce5f-a53e-c4ef-6adaf4b798f9.jpg?width=120&height=120"
            },
            {
                "title": "智能电饭煲",
                "desc": "压力IH加热技术 3L容量",
                "id": 3,
                "count": 2,
                "price": 999,
                "thumb": "https://cdn.cnbj0.fds.api.mi-img.com/b2c-mimall-media/12925f99d858e3155c4bb3ecd1f37ae7.png?width=120&height=120"
            }
        ]
    });
})
router.get('/sort_list', function (req, res, next) {
    util.res.success({
        res,
        data: {
            "list": [
                {
                    "id": 1,
                    "name": "新品"
                },
                {
                    "id": 2,
                    "name": "手机"
                },
                {
                    "id": 3,
                    "name": "电视"
                },
                {
                    "id": 4,
                    "name": "电脑"
                },
                {
                    "id": 5,
                    "name": "家电"
                },
                {
                    "id": 6,
                    "name": "路由"
                },
                {
                    "id": 7,
                    "name": "智能"
                },
                {
                    "id": 8,
                    "name": "电源"
                },
                {
                    "id": 9,
                    "name": "耳机"
                },
                {
                    "id": 10,
                    "name": "音箱"
                },
                {
                    "id": 11,
                    "name": "礼品"
                },
                {
                    "id": 12,
                    "name": "生活"
                },
                {
                    "id": 13,
                    "name": "零售"
                },
                {
                    "id": 14,
                    "name": "分类14"
                },
                {
                    "id": 15,
                    "name": "分类15"
                },
                {
                    "id": 16,
                    "name": "分类16"
                },
                {
                    "id": 17,
                    "name": "分类17"
                },
                {
                    "id": 18,
                    "name": "分类18"
                },
                {
                    "id": 19,
                    "name": "分类19"
                },
                {
                    "id": 20,
                    "name": "分类20"
                }
            ]
        }
    });
})
router.post('/goods_detail', function (req, res, next) {
    var goodsId = req.body.goods_id
    switch (goodsId) {
        case "1": {
            util.res.success({
                res,
                data: {
                    "content": "内容描述",
                    "banners": [
                        "https://i8.mifile.cn/v1/a1/334f3a68-eb80-e730-8733-48f86062cf0e.webp",
                        "https://i8.mifile.cn/v1/a1/2e34feca-9c9c-e5ff-dc39-eaac973df095.webp",
                        "https://i8.mifile.cn/v1/a1/3bf6304b-f207-a136-c763-82205f53349a.webp"
                    ],
                    "tabs": [
                        {
                            "name": "商品详情",
                            "pictures": [
                                "https://i8.mifile.cn/v1/a1/61508883-814d-1427-43d5-5cf33202e8cc.webp",
                                "https://i8.mifile.cn/v1/a1/3ed519e6-fdae-2b65-81df-1d4c0258953f.webp",
                                "https://i8.mifile.cn/v1/a1/1d682a87-1788-cec8-f222-a8534978990c.webp",
                                "https://i8.mifile.cn/v1/a1/e8ebd002-3778-ab4f-fb94-67c8bec61c69.webp"
                            ]
                        },
                        {
                            "name": "规格参数",
                            "pictures": [
                                "https://i8.mifile.cn/v1/a1/50137b8a-f0ab-1548-dfd2-1d0ce56ee92f.webp",
                                "https://i8.mifile.cn/v1/a1/6caa04b9-b8dd-ea75-8b9c-9633243c9ce6.webp",
                                "https://i8.mifile.cn/v1/a1/423cc9cc-f6f1-3ad3-a2ee-d234ddb61d13.webp",
                                "https://i8.mifile.cn/v1/a1/839825f5-5af8-3535-7edf-0e9591e4e29b.webp",
                                "https://i8.mifile.cn/v1/a1/993d0bc8-92d5-3628-7540-928660abe51c.webp",
                                "https://i8.mifile.cn/v1/a1/1717e087-9ced-8315-e4e7-729031e33dbf.webp",
                                "https://i8.mifile.cn/v1/a1/e2cd47f8-f263-6c72-67b2-92039adfe4a0.webp",
                                "https://i8.mifile.cn/v1/a1/19c92a3a-8344-ddc1-e880-e15f1f52efe1.webp",
                                "https://i8.mifile.cn/v1/a1/675698d5-fa80-b14d-a323-e91d97acb175.webp",
                                "https://i8.mifile.cn/v1/a1/62df81a3-ee47-b1c4-2604-c1f4b3b4597c.webp",
                                "https://i8.mifile.cn/v1/a1/268d578c-16f9-fcd6-4557-b16e172a2126.webp",
                                "https://i8.mifile.cn/v1/a1/8719e690-9f65-10a0-9845-7d59fde924b6.webp",
                                "https://i8.mifile.cn/v1/a1/2e4f9021-8cb7-3f9e-5cbb-6e478766a0b7.webp"
                            ]
                        }
                    ],
                    "specifications": "规格参数",
                    "inventory": "商品中包含了哪些东西的清单",
                    "id": 1,
                    "name": "小米5c 3GB+64GB 金色",
                    "description": "搭载澎湃S1 八核高性能处理器 / “暗夜之眼”超感光相机 / 135g 轻薄金属机身 / 5.15 高亮护眼屏",
                    "price": 12,
                    "thumb": "https://i8.mifile.cn/v1/a1/334f3a68-eb80-e730-8733-48f86062cf0e.webp"
                }
            });
            break;
        }
        case "2": {
            util.res.success({
                res,
                data: {
                    "content": "内容描述",
                    "banners": [
                        "http://i8.mifile.cn/v1/a1/7ebaccc9-5a10-1d71-4941-bc1c4ebba954.webp",
                        "http://i8.mifile.cn/v1/a1/74d2aa0f-62eb-6737-3d7b-c272850d3950.webp",
                        "http://i8.mifile.cn/v1/a1/15a1ae44-4007-6a3a-e8f1-512e2e87e09d.webp"
                    ],
                    "pictures": [
                        "http://i8.mifile.cn/v1/a1/7ebaccc9-5a10-1d71-4941-bc1c4ebba954.webp",
                        "http://i8.mifile.cn/v1/a1/74d2aa0f-62eb-6737-3d7b-c272850d3950.webp",
                        "http://i8.mifile.cn/v1/a1/15a1ae44-4007-6a3a-e8f1-512e2e87e09d.webp",
                        "http://i8.mifile.cn/v1/a1/02bb4430-7ff2-add0-3249-3f09810c2ef7.webp",
                        "http://i8.mifile.cn/v1/a1/d95cd554-c488-aa72-59ca-02beea4d5c02.webp",
                        "http://i8.mifile.cn/v1/a1/d95cd554-c488-aa72-59ca-02beea4d5c02.webp",
                        "http://i8.mifile.cn/v1/a1/eb48d526-52c0-c827-74c1-20079abc893d.webp",
                        "http://i8.mifile.cn/v1/a1/eb48d526-52c0-c827-74c1-20079abc893d.webp",
                        "http://i8.mifile.cn/v1/a1/bddc6dbd-d4a5-c255-f7f3-3ec764d8df79.webp",
                        "http://i8.mifile.cn/v1/a1/eb48d526-52c0-c827-74c1-20079abc893d.webp",
                        "http://i8.mifile.cn/v1/a1/4ef64a51-b1c8-f216-07b5-bcc061df099d.webp",
                        "http://i8.mifile.cn/v1/a1/13f68a5a-7a06-1468-802d-311b6ca01f11.webp",
                        "http://i8.mifile.cn/v1/a1/13f68a5a-7a06-1468-802d-311b6ca01f11.webp",
                        "http://i8.mifile.cn/v1/a1/3e6db202-804b-cdbb-e307-a3154a6eb55a.webp"
                    ],
                    "specifications": "规格参数",
                    "inventory": "商品中包含了哪些东西的清单",
                    "id": 1,
                    "name": "商品名称",
                    "description": "商品的详细描述",
                    "price": 12,
                    "thumb": "http://i9.qhimg.com/t017d891ca365ef60b5.jpg"
                }
            });
            break;
        }
        default: {
            util.res.error({
                res,
                msg: "没有数据"
            });
        }
    }
})
module.exports = router;


